package com.sosee.cgfw.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.sosee.cgfw.R;
import com.sosee.cgfw.utils.Utils;

/**
 * Created by Thinkpad on 2016/2/19.
 */
public class RiLiFragment_1 extends Fragment {

    private ImageView ig_day25;
    private ImageView ig_day26;
    private ImageView ig_day27;
    private ImageView ig_day28;
    private ImageView ig_day29;
    private ImageView ig_day30;
    private ImageView ig_day31;
    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    private int mode=0;
    //被选中状态 图片
    private int[] xuanzhong=new int[]{R.drawable.datetoday,R.drawable.day26xuanzhong,R.drawable.day27xuanzhong,R.drawable.day28xuanzhong
            ,R.drawable.day29xuanzhong,R.drawable.day30xuanzhong,R.drawable.day31xuanzhong};
    //未被选中状态图片
    private int[] weixuanzhong=new int[]{R.drawable.date25,R.drawable.date26,R.drawable.date27,R.drawable.date28,
            R.drawable.date29,R.drawable.date30,R.drawable.date31};
    //日历图片控件
    private ImageView[] ig=null;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v=null;
        if(mode==0){
            v=inflater.inflate(R.layout.fragment_rili,null);
        }else{
            v=inflater.inflate(R.layout.fragment_rili_1,null);
            ig_day25= (ImageView) v.findViewById(R.id.ig_day25);
            ig_day26= (ImageView) v.findViewById(R.id.ig_day26);
            ig_day27= (ImageView) v.findViewById(R.id.ig_day27);
            ig_day28= (ImageView)v.findViewById(R.id.ig_day28);
            ig_day29= (ImageView)v.findViewById(R.id.ig_day29);
            ig_day30= (ImageView)v.findViewById(R.id.ig_day30);
            ig_day31= (ImageView)v.findViewById(R.id.ig_day31);
            //将控件放入数组  方便后续使用
            ig=new ImageView[]{ig_day25,ig_day26,ig_day27,ig_day28,ig_day29,ig_day30,ig_day31};
        }


        return v;
    }


    //处理日历选中后的 事件
    public void doClick(int position,String date){
        Utils.day=position;
        if(mode==1&&ig!=null){
            for (int i=0;i<xuanzhong.length;i++){
                if(i==position){
                    ig[i].setImageResource(xuanzhong[i]);
                }else {
                    ig[i].setImageResource(weixuanzhong[i]);
                }
            }
        }
    }
}
